/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facade;

import entidade.Administrador;
import entidade.Aluno;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author master
 */
@Stateless
public class AdministradorFacade extends AbstractFacade<Administrador> {
    @PersistenceContext(unitName = "AvaliacaoWebPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public AdministradorFacade() {
        super(Administrador.class);
    }
    
     public Administrador retornarAdministrador(String login){
        
        String sql = "select id from administrador where nome='" + login + "'";
        Query query = em.createNativeQuery(sql);
        Integer resultadoTemp = (Integer) query.getResultList().get(0);
        Administrador temp = null;
        if(resultadoTemp != null)
            temp = find(resultadoTemp);
        
        return temp;
    }
}
